<template>
	<view class="content">
		<!-- <view class="">??{{pressListData[1].name}}</view> -->
		<view class="listBar" v-for="item,index in list" :key="index">
			<view class="title fw tac">
				<text>{{index + 1}}、</text>
				<text>{{item.name}}</text>
			</view>
<!--			<view class="message" v-for="items,indexs in item.pressList" :key="indexs" @click="click(items,index,indexs)">-->
      <view class="message" v-for="items,indexs in item.pressList" :key="indexs">
				<view class="messageBar disb aic">
					<text>{{items.categoryName}}</text>
					<view class="right disp aic">
						<image class="error" :src="items.modify?'../../static/images/order/right.png':'../../static/images/order/warnner.png'" mode=""></image>
						<text v-if="items.input">{{items.resultValue}}</text>
						<u--input
							v-else
						    placeholder="请输入内容"
							fontSize='12'
							inputAlign='right'
							:border="items.input?'none':'surround'"
							disabledColor='#fff'
							:disabled='items.input'
						    v-model="items.resultValue"
						></u--input>
						<image class="rightImg" src="../../static/images/preat/right.png" mode=""></image>
					</view>
				</view>
			</view>
		</view>
<!--		<view class="upBtn tac colorf fz12" @click="upSet">重新提交</view>-->
    <view class="upBtn tac colorf fz12" @click="goZLInfo">重新提交</view>
		<u-picker :show="show" :immediateChange="true" :columns="questionList" keyName="category" @confirm="sexSelect" @cancel='show=false' closeOnClickOverlay  @close='show=false'></u-picker>
	</view>
</template>

<script>
	import {getPublicitySelectListByClassName} from "../../api/information.js"
	import {getCantPassList,resetUp} from "../../api/search.js"
	export default {
		data() {
			return {
				show:false,
				disabled:false,
				orderId:null,
				one:null,
				two:null,
				list:[],
				questionList:[]
			};
		},
		computed:{
			
		},
		onLoad(option) {
			this.orderId = option.id
			this.getList()
		},
		methods:{
			getList(){
				let that = this
				getCantPassList({id:this.orderId}).then(res => {
					let arr = []
					for(let k in res.data){
						arr.push(res.data[k])
					}
					arr.forEach(v => {
						let obj = {}
						obj.pressList = []
						v.forEach(s => {
							s.input = true
							s.modify = false
							obj.name = s.typeName
							obj.pressList.push(s)
						})
						this.list.push(obj)
					})
				})
			},
			click(e,one,two){
				this.one = one
				this.two = two
				let parmas = {
					className:e.categoryName,
					typesName:e.typeName
				}
				getPublicitySelectListByClassName(parmas).then(res => {
					if(res.data[0].category=='手动输入'){
						this.list[this.one].pressList[this.two].input = false
						this.list[this.one].pressList[this.two].modify = true
					}else{
						this.show = true
						this.questionList = [res.data]
					}
				})
			},
			//确认选择
			sexSelect(e){
				this.show = false
				this.list[this.one].pressList[this.two].modify = true
				this.list[this.one].pressList[this.two].resultValue = e.value[0].category
			},
			//重新提交
			upSet(){
				let isAll = false
				let arr = []
				this.list.forEach(v => {
					v.pressList.forEach(s => {
						if(s.modify){
							isAll = true
							let obj = {}
							obj.id = s.id
							obj.orderId = s.orderId
							obj.categoryName = s.categoryName
							obj.resultValue = s.resultValue
							obj.typeId = ''
							obj.isPassed = '1'
							obj.typeName = s.typeName
							arr.push(obj)
						}else{
							isAll = false
							uni.$u.toast('有完善的资料，请完善后重试')
							return
						}
					})
				})
				if(isAll){
					let parmas = {
						orderId:this.orderId,
						itemList:arr
					}
					resetUp(parmas).then(res => {
						
					})
				}
			},
      goZLInfo(){
        uni.navigateTo({
          url:`/pages/search/checkInformation?id=${this.orderId}`
        })
      }
		}
	}
</script>

<style lang="scss">
.content{
	padding: 20rpx 30rpx;
	background-color: #f7f7f7;
	min-height: 100vh;
	.listBar{
		.title{
			padding: 30rpx;
			color: rgb(211, 66, 0);
		}
		.message{
			.messageBar{
				font-size: 12px;
				padding: 20rpx 30rpx;
				background-color: #fff;
				margin-bottom: 5rpx;
				.right{
					.error{
						width: 30rpx;
						height: 30rpx;
						margin-right: 20rpx;
					}
					.rightImg{
						width: 20rpx;
						height: 30rpx;
						margin-left: 20rpx;
					}
				}
			}
		}
	}
	.upBtn{
		width: 80%;
		line-height: 80rpx;
		border-radius: 40rpx;
		background-color: rgb(211, 66, 0);
		margin: 100rpx auto 0;
	}
}
</style>
